<!-- 使用 type="home" 属性设置首页，其他页面不需要设置，默认为page；推荐使用json5，更强大，且允许注释 -->
<route lang="json5">
{
  style: {
    navigationBarTitleText: '历史记录',
    enablePullDownRefresh: false,
  },
}
</route>
<template>
  <view>
    <view class="m-4">
      <k-list :loading="loading" :is-empty="!list.length">
        <template v-for="item in list" :key="item.id">
          <view v-if="item.goods" class="item mb-4">
            <around priceKey="min_price" :showSales="false" :data="item.goods"
              @click="to(`pages-sub/product/product-detail?id=${item.goods.id}`)">
              <view class="mt-auto">
                <discount-bar :price="item.goods.member_price" :levelName="item.goods.levelName" />
              </view>
            </around>
          </view>
        </template>

      </k-list>
    </view>
  </view>
</template>

<script setup>
import { to } from '@/utils/navigation'
import useReachBottomLoadMore from '@/hooks/useReachBottomLoadMore'
import { fetchHistory } from '@/service/user'
const { data: list, loading, run, params } = useReachBottomLoadMore(fetchHistory)

onLoad(() => {
  run()
})
</script>

<style lang="scss" scoped>
.item {
  padding: 20rpx 20rpx 1rpx;
  box-shadow: 0rpx 3rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
}
</style>
